<?php
	####################################################
	# library import and object instance.              #
	####################################################
	# 커먼 인클루드
	include_once( '../common.php' );

	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	//*/
	$req = Request::clean_request($_REQUEST, FALSE);
	//*/

	# GET(url variables)
	//*/
	//*/

	# POST(form variables)
	//*/
	//*/

	# Validation(special case validate)
	//*/
	//*/

	####################################################
	# implementation                                   #
	####################################################
	$sec->individual_access();
	$sec->run_cookie_check();

	# 목록을 얻는다.
	$dir = IoFileAndDir::dirmap($DEFAULT_PATH, 0, TRUE);
	//Nlog::puts($dir);
	$file_arr = array();
	foreach($dir as $key=>$val){
		if(is_array($val) == TRUE){
			foreach($val as $k=>$v){
				if($v == '.htaccess'){
					//Nlog::puts($key.$v);
					//Nlog::puts( "match" );
					$file_arr[] = $DEFAULT_PATH.$key.'/'.$v;
				}
			}
		} else {
			if($val == '.htaccess'){
				//Nlog::puts('root'.$val);
				//Nlog::puts( "match" );
				$file_arr[] = $DEFAULT_PATH.$val;
			}
		}
	}
	//Nlog::puts($file_arr);

	# 목록을 얻는뒤 파일을 파싱해온다.
	$new_file_arr = array();
	foreach($file_arr as $key=>$val){
		$file = IoFileAndDir::nfilereader($val);
		$new_file_arr[$key]['file_name'] = $val;
		$new_file_arr[$key]['file_cat'] = $file;
	}
	//Nlog::puts($new_file_arr);
?>
<?php
	# HTML START
	echo $html->custom_header(TITLE);
	echo $tplt->page_construct_javascript();
	echo $html->custom_js("{$JS}common.js");
	echo $html->custom_css("{$CSS}common.css");
	echo $html->custom_body();
?>
	<?php $tplt->app_head($NAVI)?>
	<?php $tplt->tiles_admin_sidebar($NAVI)?>
	<?php $tplt->tiles_admin_contents($pkname, $pname, $pdesc)?>

		<h4>htaccess</h4>
		<?php echo NForm::open(NULL, FALSE, "list");?>
			<?php echo NForm::mode('modify')?>
			<table class="tbl" border="0" cellpadding="3" cellspacing="0">
				<colgroup>
					<col width="40" />
					<col width="40" />
					<col width="320" />
					<col width="*" />
				</colgroup>
				<tr>
					<th><input type="checkbox" id="chkctr1" onclick="CheckboxControl.toggle_check_all('#chkctr1','.chk1');"/></th>
					<th>번호</th>
					<th>.htaccess 파일 경로</th>
					<th>.htaccess 내용</th>
				</tr>
				<?php foreach($new_file_arr as $key=>$val):?>
					<tr>
						<td>
							<input type="checkbox" name="map[<?=$key?>][uid]" id="chk1_<?=$key?>" class="chk1" value="<?=$key?>" />
						</td>
						<td><?=$key?></td>
						<td>
							<?=$val['file_name']?>
							<?php echo NForm::hidden('map['.$key.'][file_name]', $val['file_name'])?>
						</td>
						<td>
							<textarea name="map[<?=$key?>][file_cat]" onfocus="CheckboxUi.focus_to_check('#chk1_<?=$key?>');" class="inp wmatch ti0" style="height:<?=count($val['file_cat'])*18?>px;font:normal 16px/16px 'Fixedsys Excelsior 3.01';"
							><?php foreach($val['file_cat'] as $key1=>$val1):?><?=$val1?><?php endforeach;?></textarea>
						</td>
					</tr>
				<?php endforeach;?>
			</table>
		<?php echo NForm::close();?>
		<div class="tblt">
			체크된 htaccess를 : <span class="cbtn_s" onclick="$('#formx_list').submit();">수정</span>&nbsp;
		</div>
		<br />

<?php
	# HTML END
	echo $tplt->tiles_admin_footer();
	echo $tplt->page_destruct_javascript();
	include_once( '../endproc.php' );
	echo $html->html_footer();
?>